var express = require('express');
var passport=require('passport')
var router = express.Router();
var cartController = require('../controllers/cartcontroller')
// 根据用户id显示购物车信息
router.get('/', passport.authenticate('jwt', { session: false }), function (req, res, next) {

  cartController.getAllCart(req, res)

});
//删除商品
router.delete('/delCart',passport.authenticate('jwt', { session: false }), function (req, res, next) {

  cartController.delAllCart(req, res)

});
//批量删除商品
router.delete('/delCarts',passport.authenticate('jwt', { session: false }), function (req, res, next) {

  cartController.delAllCarts(req, res)

});
// 添加购物车先查询购物车
router.get('/getTypecart',passport.authenticate('jwt', { session: false }), function (req, res, next) {

  cartController.getTypecart(req, res)

});

//修改商品数量自增
router.put('/updateCart',passport.authenticate('jwt', { session: false }), function (req, res, next) {

  cartController.updateCartnum(req, res)

});
//修改商品数量自减
router.put('/updateCartsubnum',passport.authenticate('jwt', { session: false }), function (req, res, next) {

  cartController.updateCartsubnum(req, res)

});
// 向数据库里添加数据
router.post('/insertCart',passport.authenticate('jwt', { session: false }), function (req, res, next) {

  cartController.insertCart(req, res)

});
router.get('/getcartID',passport.authenticate('jwt', { session: false }), function (req, res, next) {

  cartController.getcartID(req, res)

});



module.exports = router;